Component({
  options: {
    addGlobalClass: true,
    multipleSlots: true,
  },
  data:{
    percentage:0
  },
  // 这里需要外部传递新值
  properties: {
    examid:{
      type: Number,
    },
    visited:{
      type: Number,
      value: 0
    },
    total:{
      type: Number,
      value: 0
    },
    title:{
      type: String,
      value: '标题1',
    },
    imageSrc:{
      type: String,
      value: 'edit-1',
    },
    // address: {
    //   type: Object,
    //   value: {},
    // },
    customIcon: {
      type: String,
      value: 'edit-1',
    },

    // extraSpace: {
    //   type: Boolean,
    //   value: true,
    // },
    isDrawLine: {
      type: Boolean,
      value: true,
    },
  },
  externalClasses: [
    'item-wrapper-class',
    'title-class',
    'default-tag-class',
    'normal-tag-class',
    'address-info-class',
    'delete-class',
  ],
  
  lifetimes: {
    attached: function (){
      console.log("加载时");
      const score=this.properties.visited / this.properties.total *100.0;
      console.log("score: "+score);
      this.setData({
        percentage: score
      })
    },
  },
  methods: {
   
    // 删除该访问记录
    onDelete(e) {
      // const { item } = e.currentTarget.dataset;
      console.log("删除该访问记录");
      // console.log(item);
      console.log(this.properties.examid);
      this.triggerEvent('onDelete', this.properties.examid);
    },

    
    onSelect(e) {
      const { item } = e.currentTarget.dataset;
      this.triggerEvent('onSelect', item);
    },

    // 点击了编辑按钮
    onEdit(e) {
      const { item } = e.currentTarget.dataset;
      this.triggerEvent('onEdit', item);
    },
  },
});
